package com.glsc.ngateway.common.base.domain.mysql.gateway.other;

import lombok.Data;
import lombok.ToString;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * @author libj
 * @date 2021/02/02
 * 标签信息表
 */
@Data
@ToString
@Entity
@IdClass(value = TagProdRel.PK.class)
@Table(name = "t_am_tag_prod_rel")
public class TagProdRel implements Serializable {
    static class PK implements Serializable {
        private Integer tagId;
        private Integer prodId;

        public Integer getTagId() {
            return tagId;
        }

        public Integer getProdId() {
            return prodId;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof PK)) return false;
            PK pk = (PK) o;
            return getTagId().equals(pk.getTagId()) &&
                    getProdId().equals(pk.getProdId());
        }

        @Override
        public int hashCode() {
            return Objects.hash(getTagId(), getProdId());
        }
    }

    @Id
    @Column(name = "tag_id")
    private Integer tagId;

    @Id
    @Column(name = "prod_id")
    private Integer prodId;
}



